package com.longjianghuasheng.logistics.business.order.viewmodel

import androidx.lifecycle.MutableLiveData
import com.longjianghuasheng.logistics.base.BaseMultiStateViewModel
import com.longjianghuasheng.logistics.data.model.bean.ApiResponseNoData
import com.longjianghuasheng.logistics.entity.OrderList
import com.longjianghuasheng.logistics.entity.OrderType
import com.longjianghuasheng.logistics.ext.commit
import com.longjianghuasheng.logistics.ext.commit2
import com.longjianghuasheng.logistics.ext.notNull
import com.longjianghuasheng.logistics.network.apiService

class OrderViewModel : BaseMultiStateViewModel() {


    var isLoaded = false
    var type = 0

    var status = 0

    var keywords = ""

    var id = 0

    val serviceOrderType by lazy {
        MutableLiveData<ArrayList<OrderType>>()
    }
    val result by lazy {
        MutableLiveData<OrderList>()
    }

    val deleteNotify by lazy {
        MutableLiveData<ApiResponseNoData>()
    }

    fun service_order_type() {
        commit(
            { apiService.service_order_type() },
            successLiveData = serviceOrderType,
            isToastSuccess = false,
        )
    }


    fun order_list() {

        getData2({ apiService.order_list(page, type, status, keywords) }, result)
    }

    fun order_del() {

        commit2({ apiService.order_del(id) }, deleteNotify)
    }

    val notify by lazy {
        MutableLiveData<ApiResponseNoData>()
    }

    fun order_done() {
        commit2({ apiService.order_done(id) }, notify)

    }

    var con = "";

    fun order_zjfw() {

        commit2({ apiService.order_zjfw(id, con) }, {

        })
    }

}